package com.fyi.service.impl;

import com.fyi.entity.Article;
import com.fyi.mapper.ArticleMapper;
import com.fyi.service.ArticleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class ArticleServiceImpl implements ArticleService {
    @Autowired
    private ArticleMapper articleMapper;

    @Override
    public PageInfo<Article> selectAllPageArticle(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Article> list =  articleMapper.selectAllArticle();


        //通过pageInfo包装查询结果
        PageInfo<Article> pageInfo = new PageInfo<Article>(list,5);

        return pageInfo;

    }



    @Override
    public List<Article> selectAllArticle() {
        return articleMapper.selectAllArticle();
    }

    public Article selectById(Integer id) {
        return articleMapper.selectById(id);
    }

    public Article selectByName(String name) {
        return articleMapper.selectByName(name);
    }

    public Integer addArticle(Article article) {
        return articleMapper.addArticle(article);
    }

    public Integer updateArticle(Article article) {
        return articleMapper.updateArticle(article);
    }

    public Integer deleteArticle(Integer id) {
        return articleMapper.deleteArticle(id);
    }
}
